import java.util.Scanner;

/**
 * Creater with IntelliJ IDEA.
 * Description:
 * User: 86152
 * Dae: 2022-07-27
 * Time: 16:59
 */
public class demo3 {
    public static void main(String[] args) {
        Object o = new Object();
        Thread t1 = new Thread() {
            public void run() {
                synchronized (o) {
                    System.out.println("t1运行");
                    try {
                        o.wait();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    System.out.println("t1停止");
                }
            }
        };
        Thread t2 = new Thread() {
            public void run() {
                synchronized (o) {
                    Scanner scanner = new Scanner(System.in);
                    int i = scanner.nextInt();
                    o.notify();
                }
            }
        };
        t1.start();
        t2.start();
    }
}
